package com.example.administrator.szb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.ProjectDetail;

import java.util.List;


/**
 * Created by stone on 2018/1/5.
 */

public class ProDeatilContentAdapter extends android.widget.BaseAdapter {
    private List list;

    private Context context;
    LayoutInflater inflater;
    public ProDeatilContentAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
        inflater  = LayoutInflater.from(this.context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ProjectDetail.YWInfoData getItem(int position) {
        return (ProjectDetail.YWInfoData)list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = inflater.inflate(R.layout.item,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.left_name.setText(getItem(position).getKeyName());
        holder.right_name.setText(getItem(position).getValueName());
        return convertView;
    }

    class ViewHolder{
         TextView left_name;
         TextView right_name;

        public ViewHolder(View view){
            right_name = (TextView) view.findViewById(R.id.right_name);
            left_name = (TextView) view.findViewById(R.id.left_name);
        }
    }
}
